package android.medicalcloud.com.yiapp.yilian.logic;

import android.medicalcloud.com.yiapp.base.cach.PreferceManager;
import android.medicalcloud.com.yiapp.base.net.lisener.ViewNetCallBack;
import android.medicalcloud.com.yiapp.base.utils.Logger;
import android.medicalcloud.com.yiapp.base.utils.MapBuilder;
import android.medicalcloud.com.yiapp.base.utils.StringTools;
import android.medicalcloud.com.yiapp.yilian.configer.enums.HttpConfig;
import android.medicalcloud.com.yiapp.yilian.model.BaseModeal;
import android.medicalcloud.com.yiapp.yilian.model.OrderModel;
import android.medicalcloud.com.yiapp.yilian.model.OrdersModel;
import android.medicalcloud.com.yiapp.yilian.utils.net.ConnectTool;

/**
 * Created by wanggenlin on 17-5-18.
 */
public class OrderController {
    static OrderController instance;

    private  String loginKey="UserLocalKey";
    public static OrderController getInstance() {
        if (instance == null) {
            instance = new OrderController();
        }
        return instance;
    }
    /**
     * login
     */
    public void toast(ViewNetCallBack viewNetCallBack) {
        try {
            ConnectTool.httpRequest(
                    HttpConfig.orderToast,
                    new MapBuilder<String, Object>()
                            .getMap()
                    , viewNetCallBack
                    , BaseModeal.class);
        } catch (Exception e) {
            Logger.e(e.getLocalizedMessage(), e);
        }
    }

    public void orderList(ViewNetCallBack viewNetCallBack,int state,int page,int pageSize){
        try {
            ConnectTool.httpRequest(
                    HttpConfig.orderList,
                    new MapBuilder<String, Object>()
                            .add("state",state)
                            .add("page",page)
                            .add("pageSize",pageSize)
                            .getMap()
                    , viewNetCallBack
                    , OrdersModel.class);
        } catch (Exception e) {
            Logger.e(e.getLocalizedMessage(), e);
        }
    }
    public void orderDetail(ViewNetCallBack viewNetCallBack,String  id){
        try {

            ConnectTool.httpRequest(
                    HttpConfig.orderDetail,
                    new MapBuilder<String, Object>()
                            .add("id",id)
                            .getMap()
                    , viewNetCallBack
                    , OrderModel.class);
        } catch (Exception e) {
            Logger.e(e.getLocalizedMessage(), e);
        }
    }



    public void updateState(ViewNetCallBack viewNetCallBack,String  id,String state){
        try {
            ConnectTool.httpRequest(
                    HttpConfig.orderUpdateState,
                    new MapBuilder<String, Object>()
                            .add("id",id)
                            .add("orderStatus",state)
                            .getMap()
                    , viewNetCallBack
                    , BaseModeal.class);
        } catch (Exception e) {
            Logger.e(e.getLocalizedMessage(), e);
        }
    }






}
